<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
<link rel="stylesheet" type="text/css" href="css/tao.css"/>
<link rel="stylesheet" type="text/css" href="css/yitao_header.css"/>
		<link rel="stylesheet" type="text/css" href="css/foot.css"/>
		
	</head>
	<body>
		 <script>
      //判断用户名如果存在, 则显示用户名并显示退出按钮, 否则显示注册和登录
      if (localStorage.username) {
        var oUsername = document.querySelector('a[name=username]');
        var oLogout = document.querySelector('.logout');
        oUsername.innerText = localStorage.username;
        oUsername.style.display = 'inline';
        oLogout.style.display = 'inline';
      } else {
        var oRegister = document.querySelector('.register');
        var oLogin = document.querySelector('.login');
        oRegister.style.display = 'inline';
        oLogin.style.display = 'inline';
      }
    </script>
    <script src="js/myajax.js" charset="utf-8"></script>
			<div id="yitao_header">
			<div id="yitao_header_middle">
				<div id="middle_img">
					<a href="index.html">
						<img src="img/TB1yRiUQVXXXXaAXFXXXXXXXXXX-620-220.png"/>
					</a>
				</div>
				<div id="yitao_middle_search">
    				<input class="search-text" id="search-text" type="text" placeholder="购物拿返利，手机购物更便捷">
					<div id="yitao_middle_search_right">
						<input type="submit" name="right_search" id="right_search" value="" />
					</div>
					</div>
					<div id="middle_right_img">
						<a href="">
							<img src="img/TB13Gu9OFXXXXc1apXXXXXXXXXX-620-220.png"/>
						</a>
				</div>
			</div>
		</div>










    <script>
      var oSearch = document.querySelector("#search");
      oSearch.onkeyup = function(event) {
        if (event.keyCode === 13) {
          location.href = 'search.html?search_text='+this.value;
        }
      }
    </script>
    <!--<img id="yitaologo" src="IMG/TB1yRiUQVXXXXaAXFXXXXXXXXXX-620-220.png" />-->
		<div class="daohang">
    <ul id="cat" class="cat"></ul>
		</div>
    <script>
    var oCat = document.querySelector('#cat');
    myajax.get('http://h6.duchengjiu.top/shop/api_cat.php', {}, function(error, responseText){
        var json = JSON.parse(responseText);//返回的整个json对象
        var data = json.data;//json对象当中的data是一个数组
        for (var i = 0; i < data.length; i++) {
          var obj = data[i];//数组里面的每一项是一个商品分类的对象
          oCat.innerHTML += `<li><a href="list.html?cat_id=${obj.cat_id}">${obj.cat_name}</a></li>`;
        }
    });
    </script>
  </div></header>

  <main>
  	<div class="tuda">
  <div class="tu">
    <ul id="hot-goods">
    </ul>
   </div>
   </div>
  </main>
  <script>
    //name abc
    //123

    var cat_id = getQueryString('cat_id');

    var oGoods = document.querySelector('#hot-goods');
    myajax.get('http://h6.duchengjiu.top/shop/api_goods.php',
    {cat_id: cat_id},
    (err,responseText) => {
      var json = JSON.parse(responseText);
      console.log(json);
      var data = json.data;
      //判断如果没有数据，则显示空的提示
      if (data.length === 0) {
        oGoods.innerHTML = "<center>后端程序员跑路了</center>";
        return;
      }
      for (var i = 0; i < data.length; i++) {
        var obj = data[i];
        oGoods.innerHTML += `<li class="goods"><a href="goods.html?goods_id=${obj.goods_id}">
          <div><img src="${obj.goods_thumb}" /></div>
          <div class="goods_name">${obj.goods_name}</div>
          <br>
          <div>${obj.price}</div></a>
        </li>`;
      }
    });
  </script>
  <!--底部-->
		<div id="yitao_foot">
			<div id="foot_centre">
				<div id="foot_one">
					<h2 id="foot_h2">关于我们</h2>
					<a href="" id="foot_a" title="关于一淘">关于一淘</a>
					<a href="" id="foot_a" title="法律声明">法律声明</a>
					<a href="" id="foot_a" title="诚聘英才">诚聘英才</a>
					<a href="" id="foot_a" title="廉政邮箱">廉政邮箱</a>
				</div>
				<div id="foot_two">
					<h2 id="foot_h2">帮助中心</h2>
					<a href="" id="foot_a" title="新手指南">新手指南</a>
					<a href="" id="foot_a" title="关于返利">关于返利</a>
					<a href="" id="foot_a" title="关于集分宝">关于集分宝</a>
					<a href="" id="foot_a" title="关于会员特权">关于会员特权</a>
					<a href="" id="foot_a" title="联系客服">联系客服</a>
				</div>
				<div id="foot_three">
					<h2 id="foot_h2">手机一淘</h2>
					<div id="foot_picture">
						<a href="" title="手机客户端下载">
							<img src="IMG/TB1pjAHPXXXXXc_XFXXXXXXXXXX-238-323.png"/>
						</a>
					</div>
					
				</div>
				<div id="foot_four">
					<h2 id="foot_h2">优惠地图</h2>
					<a href="" id="foot_a" title="品牌特卖">品牌特卖</a>
					<a href="" id="foot_a" title="限时闪购">限时闪购</a>
				</div>
				<div id="foot_five">
					<h2 id="foot_h2">商家合作</h2>
					<a href="" id="foot_a" title="报名入口">报名入</a>
					<a href="" id="foot_a" title="商家端问题">商家端问题</a>
				</div>
				
			</div>
		</div>
	</body>
</html>
